import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    redirect: { path: "brand1" }
  },
  {
    path: "/brand1",
    meta: {
      title: 'Brand | Company'
    },
    name: "brand1",
    component: () => import("@views/BrandCompany.vue")
  },
  {
    path: "/brand2",
    name: "brand2",
    meta: {
      title: 'Brand | CRS'
    },
    component: () => import("@views/BrandCRS.vue")
  },
  {
    path: "/brand3",
    name: "brand3",
    meta: {
      title: 'Brand | Service'
    },
    component: () => import("@views/BrandService.vue")
  },
  {
    path: "/brand4",
    name: "brand4",
    meta: {
      title: 'Brand | R&D'
    },
    component: () => import("@views/BrandRnD.vue")
  },
  {
    path: "/brand5",
    name: "brand5",
    meta: {
      title: 'Brand | Philosophy'
    },
    component: () => import("@views/BrandPhilosophy.vue")
  },
  {
    path: "/brand6",
    name: "brand6",
    meta: {
      title: 'Brand | History'
    },
    component: () => import("@views/BrandHistory.vue")
  },
  {
    path: "/lifestyle",
    name: "LifeStyle",
    meta: {
      title: 'LifeStyle'
    },
    component: () => import("@views/LifeStyle.vue")
  },
  {
    path: "/worldwide1",
    name: "WorldWideFind",
    meta: {
      title: 'WorldWide | Find A Dealer'
    },
    component: () => import("@views/WorldWideFind.vue")
  },
  {
    path: "/worldwide2",
    name: "WorldWideBook",
    meta: {
      title: 'WorldWide | Book A Car'
    },
    component: () => import("@views/WorldWideBook.vue")
  }
];

const router = new VueRouter({
  routes,
  scrollBehavior (to, from, savedPosition) {
    return {x: 0, y: 0}
  }
});
router.beforeEach((to, from, next) => {
  document.title = to.meta.title;
  next();
});
export default router;
